package org.jeecg.modules.demo.traderquota.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.demo.traderquota.entity.TraderQuota;
import org.jeecg.modules.demo.traderquota.mapper.TraderQMapper;
import org.jeecg.modules.demo.traderquota.mapper.TraderQuotaMapper;
import org.jeecg.modules.demo.traderquota.service.ITraderQService;
import org.jeecg.modules.demo.traderquota.service.ITraderQuotaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TraderQuotaServiceImpl extends ServiceImpl<TraderQuotaMapper, TraderQuota> implements ITraderQuotaService {

    @Autowired
    private TraderQuotaMapper traderQuotaMapper;
    @Autowired
    private TraderQMapper traderQMapper;

    @Override
    public List<TraderQuota> selectByMainId(String mainId) {
        return traderQuotaMapper.selectByMainId(mainId);
    }

    @Transactional
    public Double saveQuota(TraderQuota traderQuota){
        System.out.println("traderQuota: "+traderQuota);
        traderQuotaMapper.insertQuota(traderQuota);
        Double quota = traderQuotaMapper.countQuota(traderQuota.getTraderid());
//        traderQMapper.updateTraderQById(traderQuota.getTraderid(),quota);
        return quota;
    }



}
